<?php
/*
 * 相亲房秒级定时任务
 */
namespace App\Console\Commands\Tasks;
use App\Services\Tools\RedisService;
use Illuminate\Console\Command;

class ScreenOpenCommand extends Command
{
    //命令名
    protected $signature = 'task:screen_open';

    //命令描述:开启结束未开启的我要上公屏活动
    protected $description = 'open finish screen';

    public function __construct()
    {
        parent::__construct();
    }

    //业务处理
    public function handle()
    {
        $list = app('model_screen_activity')->where('stop_at', '<=', date('Y-m-d H:i:s'))->where('status',1)->get();
        $list = empty($list)?[]:$list->toArray();
        $successNum = $allNum = 0;
        foreach ($list as $k=>$v){
            $allNum ++;
            try{
                $res = app('repo_screen')->openScreenActivity($v,true);
                if($res['code'] == 200){
                    $successNum++;
                }
            }catch (\Exception $e){
            
            }
        }
        var_dump([
            'allNum'  => $allNum,
            'successNum'  => $successNum,
        ]);
    }

}
